/**
 * 这个是扩展函数，请写你自定义的函数
 */

//是否是区块链浏览器
const isDapp = () => {
	if (typeof web3 === "undefined") {
		return false;
	} else {
		return true;
	}
}

const backPage = () => {
	uni.navigateBack();
}

function getLanguage(){
	// let lang = (navigator.language || navigator.browserLanguage).toLowerCase()
	// if(lang!='zh-cn')return 'en';
	// return 'zh';	
	let lang = uni.getStorageSync('_language') || 'en';
	return lang;
}

function yy(code){
	let key = getLanguage();
	let arr = {
		"zh":{
			'env_title1':'环境检测中',
			'env_content1':'请耐心等待Dapp环境检测，非TRON的Dapp环境将无法使用本应用！',
			'env_title2':'检测失败',
			'env_content2':'请确保在Dapp环境里打开本应用，如果确实已经在Dapp环境里打开，请手动刷新一次页面！',
			'testNet':'测试网无法进行转账',
			'injectFail':'注入失败',
			'invalidAddress':'钱包地址有误',
			'invalidContractAddres':'合约地址有误',
			'invalidFromAddres':'转出钱包地址有误',
			'invalidToAddres':'转入钱包地址有误',
			'trxAmountNotEnough':'TRX余额不足，无法转账',
			'sfbAmountNotEnough':'SFB余额不足，无法转账',
			'transactionSendFail':'交易发送失败',
			'transactionSignFail':'交易签名失败',
			'transactionBroastFail':'广播交易失败',
			'transactionSFBFail':'SFB转账失败',	
			'joinNow':'现在加入',
			'joinBtn':'加入',
			'joinUsNow':'立即加入我们',
			'sponsorAddress':'推广人地址',
			'personalDetails':'个人资料',
			'tabMenu':['首页','关于我们','特点','常见问题','计划','如何开始','切换英文'],
			'all':'全部的',
			'community':'社区',
			'invest':'投资',
			'back':'退出',
			'deposit':'总存款',
			'withdraw':'总提款',	
			'refferedBy':'推荐人',
			'accountDetails':'账户详细资料',
			'chkMealMsg':'请选择要加入的套餐',
			'communityLevel':'社区层面',	
			'uplineIncome':'上线收益',
			'downlineIncome':'下线收益',	
			'affiliateLevel':'团队层面',	
			'sponsorIncome':'推广收益',	
			'totalAvailable':'可用余额',	
			'walletBalance':'钱包余额',
			'withdrawal':'提现',
			'availableAll':'可用金额',
			'availableTRX':'可用金额',
			'availableSFB':'可用金额',
			'withdrawFee':'手续费',
			'lastGetFee':'最终收益',
			'terminationInvest':'终止投资',
			'terminationBtn':'终止',
			'withdrawalTRX':'提现TRX（最少:{min} TRX）',
			'withdrawalSFB':'提现SFB（最少:{min} SFB）',
			'reinvestmentAmount':'复投金额',
			'withdrawableAmount':'提现金额',
			'withdrawInputTip':'请输入提现金额',
			'communityLevel2':'社区层级',
			'tableHeaderLevel':'层级',
			'tableHeaderID':'用户ID',
			'tableHeaderInvest':'投资',
			'tableNoData':'没有相关数据！',
			'submitBtn':'提交',
			'yourReferralLink':'我的推广链接',
			'COMPENSATIONPLAN':'奖励方案',
			'CompensationPlanPDF':'奖励方案PDF',
			'CompensationPlanVideo':'奖励方案视频',
			'copyRight':"© 版权所有 Sotheby's Union 2021。保留所有权利",
			'topBtn':'顶部',
			'copyOk':'复制分享链接成功！',	
			'sfbNotEnough':'SFB余额不足',
			'trxNotEnough':'TRX余额不足',	
			'trxInvestOk':'TRX投资成功',
			'sfbInvestOk':'SFB投资成功',	
			'inputTxOKAmout':'请输入正确的提现金额',
			'confirmTx':'是否确认提现',
			'btnNo':'否',
			'btnOK':'确认',
			'txOkTip':'提现成功',
			'confirmTer':'确认终止?',
			'terOkTip':'终止成功！',				
		},
		"en":{			
			'env_title1':'Environmental testing',
			'env_content1':'Please wait patiently for DAPP environment detection. Non Tron DAPP environment will not be able to use this application!',
			'env_title2':'Detection failed',
			'env_content2':'Please make sure to open this application in DAPP environment. If it has been opened in DAPP environment, please refresh the page manually!',
			'testNet':'The test network cannot transfer',
			'injectFail':'TronWeb Inject Fail',
			'invalidAddress':'Invalid Address',
			'invalidContractAddres':'Invalid Contract Addres',
			'invalidFromAddres':'Invalid From Addres',
			'invalidToAddres':'Invalid To Addres',
			'trxAmountNotEnough':'TRX Amount Not Enough',
			'sfbAmountNotEnough':'SFB Amount Not Enough',
			'transactionSendFail':'Transaction Send Fail',
			'transactionSignFail':'Transaction Sign Fail',
			'transactionBroastFail':'Transaction Broast Fail',
			'transactionSFBFail':'Transaction SFB Fail',			
			'joinNow':'Join Now',
			'joinBtn':'Join',
			'joinUsNow':'Join with us now.',
			'sponsorAddress':'Sponsor Address',
			'personalDetails':'Personal Details',
			'tabMenu':['Home','About us','Features','FAQ','Plan','How to start','切换中文'],
			'all':'All',
			'community':'Community',
			'invest':'Invest',
			'back':'Withdraw',
			'deposit':'Total Deposit',
			'withdraw':'Total Withdraw',
			'refferedBy':'Reffered By',
			'accountDetails':'Account Details',
			'chkMealMsg':'Please Select The Package To Join',
			'communityLevel':'Community Level',
			'uplineIncome':'Upline Income',	
			'downlineIncome':'Downline Income',
			'affiliateLevel':'Affiliate Level',
			'sponsorIncome':'Sponsor Income',	
			'totalAvailable':'Total Available',	
			'walletBalance':'Wallet Balance',
			'withdrawal':'Withdrawal',
			'availableTRX':'Available TRX',
			'availableSFB':'Available SFB',
			'availableAll':'Available',
			'withdrawFee':'Commission Charge',
			'lastGetFee':'Ultimate Yield',
			'terminationInvest':'Termination Invest',
			'terminationBtn':'Termination',
			'withdrawalTRX':'Withdrawal TRX(Min:{min} TRX)',
			'withdrawalSFB':'Withdrawal SFB(Min:{min} SFB)',
			'reinvestmentAmount':'Reinvestment Amount',
			'withdrawableAmount':'Withdrawable Amount',
			'withdrawInputTip':'Pleash input amount to withdraw',
			'communityLevel2':'Community Level',
			'tableHeaderLevel':'Level',
			'tableHeaderID':'User ID',
			'tableHeaderInvest':'Investment',
			'tableNoData':'No Data Available!',
			'submitBtn':'Submit',
			'yourReferralLink':'Your Referral Link',
			'COMPENSATIONPLAN':'COMPENSATION PLAN',
			'CompensationPlanPDF':'Compensation Plan PDF',
			'CompensationPlanVideo':'Compensation Plan Video',
			'copyRight':"© Copyright Sotheby's Union 2021. All Rights Reserved",
			'topBtn':'TOP',
			'copyOk':'Copy Success!',
			'sfbNotEnough':'Insufficient SFB balance',
			'trxNotEnough':'Insufficient TRX balance',	
			'trxInvestOk':'TRX investment success',
			'sfbInvestOk':'SFB investment success',	
			'inputTxOKAmout':'Please enter the correct withdrawal amount',
			'confirmTx':'Confirm withdrawal?',			
			'btnNo':'No',
			'btnOK':'Yes',
			'txOkTip':'Withdrawal succeeded',
			'confirmTer':'Confirm termination?',
			'terOkTip':'Termination succeeded',		
		}
	};	
	if(arr[key][code])return arr[key][code];
	return code;
}

module.exports = {
	isDapp,
	backPage,
	lang:yy,
	getLang:getLanguage
}
